import { request } from "@/utils/request";
import { SupplierAddProductsQuery } from "./types";
import Qs from "qs";

/**
 * 招商查询商品列表
 * @param query
 * @returns
 */
export const listSupplierAddProduct = (query?: SupplierAddProductsQuery) => {
  return request({
    url: "/basic/hmProducts/newList",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
    method: "post",
    data: Qs.stringify(query),
  });
};
/**
 * 研发查询商品列表
 * @param query
 * @returns
 */
export const inventList = (query?: SupplierAddProductsQuery) => {
  return request({
    url: "/basic/hmProducts/inventList",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
    method: "post",
    data: Qs.stringify(query),
  });
};
// 查询OSS对象基于id串
export function listByIds(ossId: string | number) {
  return request({
    url: "/resource/oss/listByIds/" + ossId,
    method: "get",
  });
}
/**
 * 查询商品详细
 * @param id
 */
export const getSupplierAddProducts = (id: string | number) => {
  return request({
    url: "/basic/hmProducts/" + id,
    method: "get",
  });
};
/**
 * 查询供应商添加商品详细
 * @param id
 */
export const getInfoInvent = (data: any) => {
  return request({
    url: '/basic/hmProducts/getInfoInvent',
    method: 'post',
    data
  });
};

/**
 * 查询商品详细
 * @param id 69码
 */
export const getSupplierAddProductsById = (data: any) => {
  return request({
    url: "/basic/warehouse/scanProduct",
    method: "post",
    data
  });
};
/**
 * 查询品牌列表
 * @param query
 * @returns {*}
 */
export const listBrand = (query?: any) => {
  return request({
    url: "/basic/brand/list",
    method: "get",
    params: query,
  });
};
/**
 * 类目：根据父级代码获取子类
 * @param query
 * @returns {*}
 */

export const getproductscategorychildlistbypid = (query: {
  pid?: string | number;
}) => {
  return request({
    url: "/basic/productsCategory/getproductscategorychildlistbypid",
    method: "get",
    params: query,
  });
};
/**
 * 类目：获取所有类目
 * @param query
 * @returns {*}
 */

export const getCategoryList = () => {
  return request({
    url: "/basic/category/list",
    method: "post"
  });
};

// 根据字典类型查询字典数据信息
export function getDicts(dictType: string) {
  return request({
    url: "/system/dict/data/type/" + dictType,
    method: "get",
  });
}
// oss图片上传
export function ossUpload(data: any) {
  return request({
    url: "/resource/oss/upload",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    method: "post",
    data: data,
  });
}
/**
 * 获取部门列表
 * @param
 */
export const getDeptList = (query: { parentId?: string }) => {
  return request({
    url: "/system/dept/queryList",
    method: "get",
    params: query,
  });
};
/**
 * 获取部门下的所有用户信息
 * @param deptId
 */
export const getUserById = (deptId: string) => {
  return request({
    url: "/system/user/queryList/dept/" + deptId,
    method: "get",
  });
};

/**
 * 新增商品提报
 * @param data
 */
export const addHmProducts = (data: string) => {
  return request({
    url: "/basic/hmProducts",
    method: "post",
    data: data,
  });
};

/**
 * 研发新增商品
 * @param data
 */
export const addProduct = (data: string) => {
  return request({
    url: "/basic/hmProducts/addProduct",
    method: "post",
    data: data,
  });
};

/**
 * 修改商品提报
 * @param data
 */
export const editHmProducts = (data: string) => {
  return request({
    url: "/basic/hmProducts",
    method: "put",
    data: data,
  });
};

// 研发部修改商品
export const editByInvent = (data: any) => {
  return request({
    url: "/basic/hmProducts/editByInvent",
    method: "post",
    data,
  });
};

/**
 * 修改商品为待上架
 * @param data
 */
export const editLive = (data: string) => {
  return request({
    url: "/basic/hmProducts/editLive",
    method: "post",
    data: data,
  });
};
/**
 * 修改商品为已邮寄中状态
 * @param data
 */
export const editOne = (data: any) => {
  return request({
    url: "/basic/hmProducts/editOne",
    method: "post",
    data: data,
  });
};
/**
 * 跳过邮寄状态
 * @param data
 */
export const skipProduct = (data: any) => {
  return request({
    url: "/basic/hmProducts/skipProduct",
    method: "post",
    data: data,
  });
};
/**
 * 修改商品状态为已到样
 * @param data
 */
export const editTwo = (data: any) => {
  return request({
    url: "/basic/hmProducts/editTwo",
    method: "get",
    params: data,
  });
};
/**
 * 修改商品为确认收货
 * @param data
 */
export const editThree = (data: any) => {
  return request({
    url: "/basic/hmProducts/editThree",
    method: "get",
    params: data,
  });
};
/**
 * 修改商品为待上架
 * @param data
 */
export const editFour = (data: any) => {
  return request({
    url: "/basic/hmProducts/editFour?" + data,
    method: "get"
  });
};
/**
 * 修改商品为已上架
 * @param data
 * */
export const editFive = (data: any) => {
  return request({
    url: "/basic/hmProducts/editFive?" + data,
    method: "get"
  });
};
/**
 * 修改商品为已退还
 * @param data
 * */
export const outSupplier = (data: any) => {
  return request({
    url: "/basic/hmProducts/outSupplier",
    method: "post",
    data
  });
};


/**
 * 复审重新送审
 * @param data
 * */
export const reAuditSecond = (data: any) => {
  return request({
    url: "/basic/hmProducts/reAuditSecond",
    method: "post",
    data
  });
};

/**
 * 一审二审三审无合同产品部变价 审批
 * @param id
 */
export const auditAction = (data: any) => {
  return request({
    url: `/basic/hmProducts/auditAction`,
    method: 'post',
    data
  });
};

/**
 * 修改商品为下架
 * @param data
 */
export const editOff = (data: any) => {
  return request({
    url: "/basic/hmProducts/editOff?" + data,
    method: "get",
  });
};

/**
 * 获取所有主播
 * @param data
 */
export const getAnchorList = (query: any) => {
  return request({
    url: "/system/user/queryList",
    method: "get",
    params: query,
  });
};
/**
 * 获取所有主播 dept
 * @param query
 * @returns
 */
export const queryOperationDeptList = () => {
  return request({
    url: '/system/dept/queryOperationDeptList',
    method: 'get',
  });
};

/**
 * 改版获取所有主播
 * @param data
 */
export const deptTree = (query: any) => {
  return request({
    url: "/system/dept/deptTree",
    method: "get",
    params: query,
  });
};

/**
 * 根据主播用户id查询部门
 * @param data
 */
export const queryUserIdByDeptId = (query: any) => {
  return request({
    url: "/basic/hmProducts/queryUserIdByDeptId",
    method: "get",
    params: query,
  });
};

/**
 * 修改主播接口
 * @param data
 */
export const changeCore = (data: any) => {
  return request({
    url: "/basic/hmProducts/changeCore",
    method: "post",
    data: data,
  });
};

/**
 * 修改主播是否重新送审
 * @param data
 */
export const changeCoreIsAudit = (data: any) => {
  return request({
    url: "/basic/hmProducts/changeCoreIsAudit",
    method: "post",
    data: data,
  });
};

/**
 * 修改商品为待送审
 * @param data
 */
export const editCore = (data: any) => {
  return request({
    url: "/basic/hmProducts/core",
    method: "post",
    data: data,
  });
};

/**
 * 修改商品为待审核
 * @param data
 */
export const editSeven = (data: any) => {
  return request({
    url: "/basic/hmProducts/editSeven?" + data,
    method: "get",
  });
};
export const editSevens = (data: any) => {
  return request({
    url: "/basic/hmProducts/editSeven",
    method: "post",
    data
  });
};


/**
 * 修改商品为不通过
 * @param data
 */
export const editEight = (data: any) => {
  return request({
    url: "/basic/hmProducts/editEight",
    method: "get",
    params: data,
  });
};

/**
 * 修改商品为通过
 * @param data
 */
export const editNine = (data: any) => {
  return request({
    url: "/basic/hmProducts/editNine",
    method: "get",
    params: data,
  });
};

/**
 * 修改商品为已入库
 * @param data
 */
export const editTen = (data: any) => {
  return request({
    url: "/basic/hmProducts/editTen?" + data,
    method: "get",
  });
};

/**
 * 查询已选品商品列表
 * @param query
 * @returns
 */
export const optListSupplierAddProduct = (query?: SupplierAddProductsQuery) => {
  return request({
    url: "/basic/hmProducts/optList",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
    method: "post",
    data: Qs.stringify(query),
  });
};

/**
 * 获取首页待办工作数量
 * @param data
 */
export const getTotal = (data?: any) => {
  return request({
    url: "/basic/hmProducts/total",
    method: "post",
    data: data,
  });
};

/**
 * 研发获取首页待办工作数量
 * @param data
 */
export const getTotalInvent = (data?: any) => {
  return request({
    url: "/basic/hmProducts/getTotalInvent",
    method: "post",
    data: data,
  });
};

/**
 * 获取首页六条数据 数量
 * @param data
 */
export const totalByUserIdAndTime = (data: any) => {
  return request({
    url: "/basic/hmProducts/timeTotal",
    method: "get",
    params: data,
  });
};

/**
 * 研发获取首页六条数据 数量
 * @param data
 */
export const inventTimeTotal = (data: any) => {
  return request({
    url: "/basic/hmProducts/inventTimeTotal",
    method: "get",
    params: data,
  });
};

/**
 * 首页按照时间查询新增商品数据
 * @param data
 */
export const selectAddProductsStatistics = (data: any) => {
  return request({
    url: "/basic/hmProducts/selectAddProductsStatistics",
    method: "get",
    params: data,
  });
};

/**
 * 首页按照时间查询上架商品数据
 * @param data
 */
export const selectListingProductsStatistics = (data: any) => {
  return request({
    url: "/basic/hmProducts/selectListingProductsStatistics",
    method: "get",
    params: data,
  });
};

/**
 * 研发-首页按照时间查询上架商品数据
 * @param data
 */
export const getShoppingListInvent = (data: any) => {
  return request({
    url: "/basic/hmProducts/getShoppingListInvent",
    method: "get",
    params: data,
  });
};

/**
 * 首页按照时间查询主播选品数据
 * @param data
 */
export const selectAnchorSelectionStatistics = (data: any) => {
  return request({
    url: "/basic/hmProducts/selectAnchorSelectionStatistics",
    method: "get",
    params: data,
  });
};

/**
 * 研发-首页按照时间查询主播选品数据
 * @param data
 */
export const getOptListInvent = (data: any) => {
  return request({
    url: "/basic/hmProducts/getOptListInvent",
    method: "get",
    params: data,
  });
};

/**
 * 研发-首页按照时间查询暂无大货数据
 * @param data
 */
export const getNoBigVideoListInvent = (data: any) => {
  return request({
    url: "/basic/hmProducts/getNoBigVideoListInvent",
    method: "get",
    params: data,
  });
};

/**
 * 首页按照时间查询入库商品数据
 * @param data
 */
export const selectWarehousingProductsStatistics = (data: any) => {
  return request({
    url: "/basic/hmProducts/selectWarehousingProductsStatistics",
    method: "get",
    params: data,
  });
};

/**
 * 首页按照时间查询建联商家数据
 * @param data
 */
export const selectJLMerchantStatistics = (data: any) => {
  return request({
    url: "/basic/hmProducts/selectJLMerchantStatistics",
    method: "get",
    params: data,
  });
};

/**
 * 研发部-首页按照时间查询建联商家数据
 * @param data
 */
export const getJLMerchantStatisticsInvent = (data: any) => {
  return request({
    url: "/basic/hmProducts/getJLMerchantStatisticsInvent",
    method: "get",
    params: data,
  });
};

/**
 * 首页按照时间查询签署合同数据
 * @param data
 */
export const selectSignContractStatistics = (data: any) => {
  return request({
    url: "/basic/hmProducts/selectSignContractStatistics",
    method: "get",
    params: data,
  });
};

/**
 * 无合同审批入库
 * @param data
 */
export const noContractAdd = (data: any) => {
  return request({
    url: "/basic/contractAudit/noContractAdd",
    method: "post",
    data: data,
  });
};

/**
 * 无合同审批查询列表
 * @param data
 */
export const selectContractAuditList = (data: any) => {
  return request({
    url: "/basic/contractAudit/selectContractAuditList",
    method: "get",
    params: data,
  });
};

/**
 * 获取无合同审批商品详细信息
 * @param data
 */
export const contractAudit = (id: string) => {
  return request({
    url: "/basic/contractAudit/" + id,
    method: "get",
  });
};

/**
 * 审核经理无合同审批
 * @param data
 */
export const noContractUpdate = (data: any) => {
  return request({
    url: "/basic/contractAudit/noContractUpdate",
    method: "post",
    data: data,
  });
};

/**
 * app品控重新送审
 * @param data
 */
export const againQuality = (data: any) => {
  return request({
    url: "/basic/quality/againQuality",
    method: "post",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
    data: Qs.stringify(data),
  });
};

/**
 * 核价重新送审
 * @param data
 */
export const againPricing = (query: any) => {
  return request({
    url: "/basic/pricing/againPricing",
    method: "post",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
    data: Qs.stringify(query),
  });
};

// 查询商品类目
export const categoryList = (data: any) => {
  return request({
    url: "/basic/category/list",
    method: "post",
    data,
  });
};

// 获取部门列表
export function passerList(data) {
  return request({
    url: "/supplier/passer/list",
    method: "post",
    params: data,
  });
}
//获取部门下的所有用户信息
export function getUserList(data) {
  return request({
    url: "/supplier/passer/getUserList",
    method: "post",
    params: data,
  });
}

//发起组长审批
export function requestGroup(data) {
  return request({
    url: "/basic/hmProducts/requestGroup",
    method: "post",
    data: data,
  });
}

//发起总监初审审批
export function reAuditSecondInvent(data) {
  return request({
    url: "/basic/hmProducts/reAuditSecondInvent",
    method: "post",
    data: data,
  });
}

//发起总监复核审批
export function requestThirdInvent(data) {
  return request({
    url: "/basic/hmProducts/requestThirdInvent",
    method: "post",
    data: data,
  });
}










// 产品部接口
// 商品列表
export const queryProductList = (data: any) => {
  return request({
    url: "/basic/warehouse/queryProduct",
    method: "post",
    data
  });
};


// 招商部商品变更招商员
export const transferProduct = (data: any) => {
  return request({
    url: "/basic/hmProducts/transferProduct",
    method: "post",
    data
  });
};

// 新招商审批列表查询
export const getAuditList = (data: any) => {
  return request({
    url: "/basic/examine/getAuditList",
    method: "post",
    data
  });
};

// 新招商审批列表详情查询
export const getProductDetailed = (data: any) => {
  return request({
    url: "/basic/examine/getProductDetailed",
    method: "post",
    data
  });
};


// 发起变价
export const changeAudit = (data: any) => {
  return request({
    url: "/basic/changeAudit/add",
    method: "post",
    data
  });
};

/**
 * 研发部修改商品为已上架
 * @param data
 * */
export const publishInvent = (data: any) => {
  return request({
    url: "/basic/hmProducts/publishInvent?" + data,
    method: "get"
  });
};
/**
 * 研发部修改商品为待送审 ==> 已选品
 * @param data
 */
export const coreInvent = (data: any) => {
  return request({
    url: "/basic/hmProducts/coreInvent",
    method: "post",
    data: data,
  });
};


// 研发审批组长审批列表
export const getFirstLogInventPe = (data: any) => {
  return request({
    url: "/basic/hmProducts/getFirstLogInventPe",
    method: "post",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
    data: Qs.stringify(data),
  });
};



// 组长列表查看详情
export function getFirstDetailsByIdInvent(data: { id: string }) {
  return request({
    url: "/basic/hmProducts/getFirstDetailsByIdInvent",
    method: 'post',
    data
  });
}

// 总监初审列表审批列表
export function getSecondLogInventPe(data: { id: string }) {
  return request({
    url: "/basic/hmProducts/getSecondLogInventPe",
    method: "post",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
    data: Qs.stringify(data),
  });
}
// 总监初审列表查看详情
export function getSecondDetailsByIdInvent(data: { id: string }) {
  return request({
    url: "/basic/hmProducts/getSecondDetailsByIdInvent",
    method: 'post',
    data
  });
}
// 总监复核列表审批列表
export function getThirdLogInventPe(data: { id: string }) {
  return request({
    url: "/basic/hmProducts/getThirdLogInventPe",
    method: "post",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
    data: Qs.stringify(data),
  });
}
// 总监初审列表查看详情
export function getThirdDetailsByIdInvent(data: { id: string }) {
  return request({
    url: "/basic/hmProducts/getThirdDetailsByIdInvent",
    method: 'post',
    data
  });
}

// 一审列表审批列表
export function getPriceFirstListInventPe(data: { id: string }) {
  return request({
    url: "/basic/hmProducts/getPriceFirstListInventPe",
    method: "post",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
    data: Qs.stringify(data),
  });
}

// 一审查看详情
export function getDetailsById(data: { id: string }) {
  return request({
    url: "/basic/hmProducts/getFirstDetailsById",
    method: 'post',
    data
  });
}

// 复审列表审批列表
export function getPriceSecondListInventPe(data: { id: string }) {
  return request({
    url: "/basic/hmProducts/getPriceSecondListInventPe",
    method: "post",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
    data: Qs.stringify(data),
  });
}
// PC核价二审查看详情
export function getSecondDetailsById(data: { id: string }) {
  return request({
    url: "/basic/hmProducts/getSecondDetailsById",
    method: 'post',
    data
  });
}
// 无合同列表审批列表
export function getContractFirstListInventPe(data: { id: string }) {
  return request({
    url: "/basic/contractAudit/getContractFirstListInventPe",
    method: "post",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
    data: Qs.stringify(data),
  });
}


// 入库列表审批列表
export function getStockListInventPe(data: { id: string }) {
  return request({
    url: "/basic/stock/getStockListInventPe",
    method: "post",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
    data: Qs.stringify(data),
  });
}
// 入库列表审批列表详情
export function getStockById(data: any) {
  return request({
    url: "/basic/stock/getStockPcList",
    method: "post",
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
    data: Qs.stringify(data),
  });
}

// 变价审批列表
export function getStockPriceInventPe(data: { id: string }) {
  return request({
    url: "/basic/changeAudit/getStockPriceInventPe",
    method: "post",
    data
  });
}
// 变价审批列表详情
export function getPricingById(data: any) {
  return request({
    url: '/basic/changeAudit/getPricingById',
    method: 'post',
    data: data
  });
}
  // 快递单号查询物流信息
  export function getDeliveryInfo(data: any){
  	return request({
  	  url: '/basic/delivery/getDeliveryInfo',
  	  method: 'post',
  	  data: data
  	});
}

//通过快递单号和代号查询物流轨迹
export function getLogisticsTraceDetailList(params?: any){
  return request({
    url: '/basic/hmProducts/getLogisticsTraceDetailList',
    method: 'get',
    params: params
  });
}

//超时测试接口
export const editTest = (data: string) => {
  return request({
    url: "/basic/hmSupplier/editTest",   //超时
    // url: "/basic/hmSupplier/editTestOne",   //500
    // url: "/basic/hmSupplier/editTestTwo",   //鉴权失败
    method: "post",
    data: data,
  });
};